﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace DongFangGuoKai.TaskPlatform.Commn.ExtensionModule
{
    public static partial class Extension
    {
        public static string GetDisplayName(this Enum eum)
        {
            var type = eum.GetType(); //先获取这个枚举的类型
            var field = type.GetField(eum.ToString()); //通过这个类型获取到值
            var obj = field.GetCustomAttribute<DescriptionAttribute>(); //得到特性
            return obj.Description ?? "";

        }
    }
}
